package com.jerry.mingxing.ui.store;

import android.os.Handler;

import com.jerry.mingxing.bean.ShowBean;
import com.jerry.mingxing.bean.StoreBean;

import java.util.HashMap;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by Administrator on 2016/8/30.
 */
public class StoreContentPresenter implements StoreContentContract.Presenter {
    private StoreContentContract.Mode mode;
    private StoreContentContract.View view;
    public StoreContentPresenter(StoreContentContract.View view){
        this.view=view;
        this.mode=new StoreContentMode();
    }

    @Override
    public void loadStoreContentKorea() {
        mode.loadStoreContentKorea(new Callback<StoreBean>() {
            @Override
            public void onResponse(Call<StoreBean> call, Response<StoreBean> response) {
                final StoreBean bean = response.body();
                Handler handler=new Handler();
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.onResponseKorea(bean);
                    }
                });
            }

            @Override
            public void onFailure(Call<StoreBean> call, Throwable t) {
                view.onFailureKorea(t.toString());
            }
        });
    }

    @Override
    public void loadStoreContentUsa() {
        mode.loadStoreContentUsa(new Callback<StoreBean>() {
            @Override
            public void onResponse(Call<StoreBean> call, Response<StoreBean> response) {
                final StoreBean bean = response.body();
                Handler handler=new Handler();
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.onResponseUsa(bean);
                    }
                });
            }

            @Override
            public void onFailure(Call<StoreBean> call, Throwable t) {
                view.onFailureUsa(t.toString());
            }
        });
    }

    @Override
    public void loadStoreContentChiness() {
        mode.loadStoreContentChiness(new Callback<StoreBean>() {
            @Override
            public void onResponse(Call<StoreBean> call, Response<StoreBean> response) {
                final StoreBean bean = response.body();
                Handler handler=new Handler();
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.onResponseChinese(bean);
                    }
                });
            }

            @Override
            public void onFailure(Call<StoreBean> call, Throwable t) {
                view.onFailureChinese(t.toString());
            }
        });

    }

    @Override
    public void loadStoreContentBeauty() {
        mode.loadStoreContentBeauty(new Callback<StoreBean>() {
            @Override
            public void onResponse(Call<StoreBean> call, Response<StoreBean> response) {
                final StoreBean bean = response.body();
                Handler handler=new Handler();
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.onResponseBeauty(bean);
                    }
                });
            }

            @Override
            public void onFailure(Call<StoreBean> call, Throwable t) {
                view.onFailureBeauty(t.toString());
            }
        });

    }

    @Override
    public void loadShowToday() {
        mode.loadShowToday(new Callback<ShowBean>() {
            @Override
            public void onResponse(Call<ShowBean> call, Response<ShowBean> response) {
                final ShowBean bean = response.body();
                Handler handler=new Handler();
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.onResponseShow(bean);
                    }
                });
            }

            @Override
            public void onFailure(Call<ShowBean> call, Throwable t) {
                view.onFailureBeauty(t.toString());
            }
        });
    }

    @Override
    public void loadShowUp() {
        mode.loadShowUp(new Callback<ShowBean>() {
            @Override
            public void onResponse(Call<ShowBean> call, Response<ShowBean> response) {
                final ShowBean bean = response.body();
                Handler handler=new Handler();
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.onResponseShow(bean);
                    }
                });
            }

            @Override
            public void onFailure(Call<ShowBean> call, Throwable t) {
                view.onFailureBeauty(t.toString());
            }
        });
    }

    @Override
    public void loadShowDress() {
        mode.loadShowDress(new Callback<ShowBean>() {
            @Override
            public void onResponse(Call<ShowBean> call, Response<ShowBean> response) {
                final ShowBean bean = response.body();
                Handler handler=new Handler();
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.onResponseShow(bean);
                    }
                });
            }

            @Override
            public void onFailure(Call<ShowBean> call, Throwable t) {
                view.onFailureBeauty(t.toString());
            }
        });
    }

    @Override
    public void loadShowTrousers() {
        mode.loadShowTrousers(new Callback<ShowBean>() {
            @Override
            public void onResponse(Call<ShowBean> call, Response<ShowBean> response) {
                final ShowBean bean = response.body();
                Handler handler=new Handler();
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.onResponseShow(bean);
                    }
                });
            }

            @Override
            public void onFailure(Call<ShowBean> call, Throwable t) {
                view.onFailureBeauty(t.toString());
            }
        });
    }


}
